import 'dart:io';

import 'package:flutter/material.dart';
import '../../common_layouts/back_title.dart';
import '../../Constants/constants.dart';
import '../../common_layouts/full_fun_iconbtn.dart';
import '../../common_layouts/split_layout.dart';
import '../../Constants/styles/app_style.dart';
import 'package:flutter/services.dart';

class SettingPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(AppColors.MainBgColor),
      //backgroundColor:Colors.blue,
      body:SafeArea(child: Column(
        children: <Widget>[
          BackTitle(pressed: (){Navigator.pop(context);},title: '设置',),
          FullFunIconBtn(
            iconPath: 'assets/images/ima_emotions.png',
            title: '账号与安全',
            hasDivider: false,
            hasPic: false,
            pressed: () {},
          ),
          SplitLayout(),
          _returnLayout('退出',(){
            showModalBottomSheet<void>(
              context: context,
              builder: (BuildContext cotxt){
                return _popLay(cotxt);
              }
            );
          }),
          Divider(height: 1,color: Color(AppColors.SpliteLineColor))
        ],
      ))
    );
  }

  FlatButton _returnLayout(String title,VoidCallback pressed){
    return FlatButton( 
     shape: RoundedRectangleBorder(
           side: BorderSide(width: 0, color: Colors.transparent)),
      color:Colors.white,
      onPressed:pressed,
      child:Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
         Container(
           padding:  EdgeInsets.only(top:Constants.Hh*41,bottom: Constants.Hh*41),
           child: Text(title,textAlign: TextAlign.center, style: TextStyleNw.listItemMain),
         )
        ],
      )
      );
  }

  Container _popLay(BuildContext context){
    return 
    Container(
      decoration: BoxDecoration(borderRadius:BorderRadius.all(Radius.circular(10)),),
      //color: Color(AppColors.WhiteColor),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children:[
            _returnLayout('退出登录',(){
              Navigator.of(context).pushNamedAndRemoveUntil('/loginPage', (Route<dynamic> route) => false);
             
            }),
            Divider(height: 1,color: Color(AppColors.SpliteLineColor)),
            _returnLayout('关闭微信',(){
               exit(0);
               //SystemChannels.platform.invokeMethod('SystemNavigator.pop');
               //https://www.cnblogs.com/wf-l5201314/p/10796495.html
            }),
            Divider(height: 1,color: Color(AppColors.SpliteLineColor)),
            _returnLayout('取消',(){
               Navigator.pop(context);
            }),
        ]
      ),
    );
  }
}

